package com.file.system.entity.system;


import com.file.system.entity.basic.WebBasic;
import com.file.system.plugin.dict.Dict;
import com.file.system.plugin.validated.SQLInjectionValidation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
import java.io.Serializable;


/**
 * 定时任务
 *
 * @author jch
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WebTask extends WebBasic implements Serializable {

    private static final long serialVersionUID = 1L;


    //新增
    public interface add extends Default {
    }

    //修改
    public interface update extends Default {
    }

    /**
     * 主键
     */
    @NotNull(groups = {update.class}, message = "主键不能为空")
    @Min(value = 1, message = "id长度最小1")
    private Long id;
    /**
     * 任务名称
     */
    @NotEmpty(groups = {update.class, add.class}, message = "任务名称不能为空")
    @Size(min = 1, max = 100, message = "任务名称长度1-100")
    @SQLInjectionValidation(fieldName = "任务名称")
    private String name;
    /**
     * cron表达式
     */
    @NotEmpty(groups = {update.class, add.class}, message = "cron表达式不能为空")
    @Size(min = 1, max = 100, message = "cron表达式长度1-100")
    @SQLInjectionValidation(fieldName = "cron表达式")
    private String cron;
    /**
     * 类名全路径
     */
    @NotEmpty(groups = {update.class, add.class}, message = "类名全路径不能为空")
    @Size(min = 1, max = 200, message = "类名全路径长度1-200")
    @SQLInjectionValidation(fieldName = "类名全路径", enableValidation = false)
    private String className;
    /**
     * 任务分类（字典）（字典）
     */
    @NotEmpty(groups = {update.class, add.class}, message = "任务分类（字典）不能为空")
    @Size(min = 1, max = 20, message = "任务分类（字典）长度1-20")
    @Dict("dictGroup")
    @SQLInjectionValidation(fieldName = "任务分类（字典）")
    private String dictGroup;
    /**
     * 定时任务启动状态（字典）（字典）
     */
    @NotEmpty(groups = {update.class, add.class}, message = "定时任务启动状态（字典）不能为空")
    @Size(min = 1, max = 20, message = "定时任务启动状态（字典）长度1-20")
    @Dict("taskStart")
    @SQLInjectionValidation(fieldName = "定时任务启动状态（字典）")
    private String dictTaskStart;
    /**
     * 启用禁用（字典）（字典）
     */
    @NotEmpty(groups = {update.class, add.class}, message = "启用禁用（字典）不能为空")
    @Size(min = 1, max = 20, message = "启用禁用（字典）长度1-20")
    @Dict("onOff")
    @SQLInjectionValidation(fieldName = "启用禁用（字典）")
    private String dictOnOff;
}
